package com.lib.net.util;

import android.content.Context;
import android.content.SharedPreferences;

public class SharedPreferenceUtils {
    private static SharedPreferenceUtils instance;
    private Context mContext;
    private SharedPreferences preferences;
    private SharedPreferences.Editor editor;

    private SharedPreferenceUtils() {
    }

    public void init(Context context, String name) {
        this.mContext = context;
        Context var10003 = this.mContext;
        this.preferences = context.getSharedPreferences(name, 0);
        this.editor = this.preferences.edit();
    }

    public static SharedPreferenceUtils getInstance() {
        if (instance != null) {
            return instance;
        } else {
            Class var0 = SharedPreferenceUtils.class;
            synchronized(SharedPreferenceUtils.class) {
                if (instance != null) {
                    return instance;
                } else {
                    instance = new SharedPreferenceUtils();
                    return instance;
                }
            }
        }
    }

    public void putString(String key, String value) {
        this.editor.putString(key, value);
        this.editor.commit();
    }

    public void putInt(String key, int value) {
        this.editor.putInt(key, value);
        this.editor.commit();
    }

    public void putFloat(String key, float value) {
        this.editor.putFloat(key, value);
        this.editor.commit();
    }

    public void putLong(String key, long value) {
        this.editor.putLong(key, value);
        this.editor.commit();
    }

    public void putBoolean(String key, boolean value) {
        this.editor.putBoolean(key, value);
        this.editor.commit();
    }

    public String getString(String key, String defValue) {
        return this.preferences.getString(key, defValue);
    }

    public int getInt(String key, int defValue) {
        return this.preferences.getInt(key, defValue);
    }

    public Float getFloat(String key, Float defValue) {
        return this.preferences.getFloat(key, defValue);
    }

    public Long getLong(String key, Long defValue) {
        return this.preferences.getLong(key, defValue);
    }

    public boolean getBoolean(String key, boolean defValue) {
        return this.preferences.getBoolean(key, defValue);
    }

    public String getString(String key) {
        return this.preferences.getString(key, "");
    }

    public int getInt(String key) {
        return this.preferences.getInt(key, 0);
    }

    public boolean getBoolean(String key) {
        return this.preferences.getBoolean(key, false);
    }

    public void remove(String key) {
        this.editor.remove(key);
        this.editor.commit();
    }

    public void clearAll() {
        this.editor.clear();
        this.editor.commit();
    }


}
